X-Git-Url: http://git.cyclocoop.org//%22http:/%22.attribut_html%28%24lesurls%5B%24numero%5D%29.%22/%22?a=blobdiff_plain;f=maintenance%2FrebuildFileCache.php;h=1f89426e7aebcf600dec94d3b189ce59934d4482;hb=4f942e4377c3f8fcaabb29a41c164ae3f319cd80;hp=19d8d061546436d29db65ccaf46f92c6ad4a81dd;hpb=55a9b2f8b6463f94a35e5e914167de2357961c19;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/rebuildFileCache.php b/maintenance/rebuildFileCache.php index 19d8d06154..1f89426e7a 100644 --- a/maintenance/rebuildFileCache.php +++ b/maintenance/rebuildFileCache.php @@ -57,21 +57,19 @@ class RebuildFileCache extends Maintenance { } public function execute() { - global $wgRequestTime; - if ( !$this->enabled ) { - $this->error( "Nothing to do -- \$wgUseFileCache is disabled.", true ); + $this->fatalError( "Nothing to do -- \$wgUseFileCache is disabled." ); } $start = $this->getOption( 'start', "0" ); if ( !ctype_digit( $start ) ) { - $this->error( "Invalid value for start parameter.", true ); + $this->fatalError( "Invalid value for start parameter." ); } $start = intval( $start ); $end = $this->getOption( 'end', "0" ); if ( !ctype_digit( $end ) ) { - $this->error( "Invalid value for end parameter.", true ); + $this->fatalError( "Invalid value for end parameter." ); } $end = intval( $end ); @@ -82,15 +80,16 @@ class RebuildFileCache extends Maintenance { $overwrite = $this->hasOption( 'overwrite' ); $start = ( $start > 0 ) ? $start - : $dbr->selectField( 'page', 'MIN(page_id)', false, __METHOD__ ); + : $dbr->selectField( 'page', 'MIN(page_id)', '', __METHOD__ ); $end = ( $end > 0 ) ? $end - : $dbr->selectField( 'page', 'MAX(page_id)', false, __METHOD__ ); + : $dbr->selectField( 'page', 'MAX(page_id)', '', __METHOD__ ); if ( !$start ) { - $this->error( "Nothing to do.", true ); + $this->fatalError( "Nothing to do." ); } - $_SERVER['HTTP_ACCEPT_ENCODING'] = 'bgzip'; // hack, no real client + // Mock request (hack, no real client) + $_SERVER['HTTP_ACCEPT_ENCODING'] = 'bgzip'; # Do remaining chunk $end += $batchSize - 1; @@ -104,7 +103,7 @@ class RebuildFileCache extends Maintenance { $res = $dbr->select( 'page', [ 'page_namespace', 'page_title', 'page_id' ], [ 'page_namespace' => MWNamespace::getContentNamespaces(), - "page_id BETWEEN $blockStart AND $blockEnd" ], + "page_id BETWEEN " . (int)$blockStart . " AND " . (int)$blockEnd ], __METHOD__, [ 'ORDER BY' => 'page_id ASC', 'USE INDEX' => 'PRIMARY' ] ); @@ -140,24 +139,29 @@ class RebuildFileCache extends Maintenance { } } - MediaWiki\suppressWarnings(); // header notices - // Cache ?action=view - $wgRequestTime = microtime( true ); # T24852 + Wikimedia\suppressWarnings(); // header notices + + // 1. Cache ?action=view + // Be sure to reset the mocked request time (T24852) + $_SERVER['REQUEST_TIME_FLOAT'] = microtime( true ); ob_start(); $article->view(); $context->getOutput()->output(); $context->getOutput()->clearHTML(); $viewHtml = ob_get_clean(); $viewCache->saveToFileCache( $viewHtml ); - // Cache ?action=history - $wgRequestTime = microtime( true ); # T24852 + + // 2. Cache ?action=history + // Be sure to reset the mocked request time (T24852) + $_SERVER['REQUEST_TIME_FLOAT'] = microtime( true ); ob_start(); Action::factory( 'history', $article, $context )->show(); $context->getOutput()->output(); $context->getOutput()->clearHTML(); $historyHtml = ob_get_clean(); $historyCache->saveToFileCache( $historyHtml ); - MediaWiki\restoreWarnings(); + + Wikimedia\restoreWarnings(); if ( $rebuilt ) { $this->output( "Re-cached page '$title' (id {$row->page_id})..." ); @@ -179,5 +183,5 @@ class RebuildFileCache extends Maintenance { } } -$maintClass = "RebuildFileCache"; +$maintClass = RebuildFileCache::class; require_once RUN_MAINTENANCE_IF_MAIN;